package com.pet.server.po;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Formula;

/**
 * @author Administrator
 *
 */
@Entity
@Table(name = "user_task")
public class UserTask implements java.io.Serializable {

	// Fields

		private Integer id;
		private Integer userId;
		private String nickName;
		private String taskId;
		private String taskName;
		//完成次数
		private Integer time;
		//是否领取
		private Integer received;
		
		private Date createdTime;
		
		private String state;
	// Constructors

	/** default constructor */
	public UserTask() {
	}

	/** full constructor */
	public UserTask(Integer id, Integer userId, String taskId, String taskName,
			Integer time, Integer received, Date createdTime) {
		super();
		this.id = id;
		this.userId = userId;
		this.taskId = taskId;
		this.taskName = taskName;
		this.time = time;
		this.received = received;
		this.createdTime = createdTime;
	}

	// Property accessors
		@Id
		@GeneratedValue(strategy = IDENTITY)
		@Column(name = "id", unique = true, nullable = false)
		public Integer getId() {
			return this.id;
		}

		
		public void setId(Integer id) {
			this.id = id;
		}

		@Column(name = "task_id", nullable = false, length = 20)
		public String getTaskId() {
			return this.taskId;
		}

		public void setTaskId(String taskId) {
			this.taskId = taskId;
		}

		@Formula("(SELECT d.task_name FROM task_info d WHERE d.task_id=task_id)")
		public String getTaskName() {
			return this.taskName;
		}

		public void setTaskName(String taskName) {
			this.taskName = taskName;
		}

		@Column(name = "user_id", unique = true, nullable = false)
		public Integer getUserId() {
			return userId;
		}

		
		public void setUserId(Integer userId) {
			this.userId = userId;
		}

		@Column(name = "time", length = 32)
		public Integer getTime() {
			return time;
		}

		
		public void setTime(Integer time) {
			this.time = time;
		}

		@Column(name = "received", length = 32)
		public Integer getReceived() {
			return received;
		}

		
		public void setReceived(Integer received) {
			this.received = received;
		}

		@Column(name = "created_time", nullable = false, length = 0)
		public Date getCreatedTime() {
			return createdTime;
		}

		public void setCreatedTime(Date createdTime) {
			this.createdTime = createdTime;
		}

		@Formula("(SELECT f.nick_name FROM user_info f WHERE f.user_id=user_id)")
		public String getNickName() {
			return nickName;
		}

		
		public void setNickName(String nickName) {
			this.nickName = nickName;
		}

		/**
		 * @return the state
		 */
		@Column(name = "state", nullable = false, length = 32)
		public String getState() {
			return state;
		}


		/**
		 * @param state the state to set
		 */
		public void setState(String state) {
			this.state = state;
		}
}